package com.xie.system.domain.message.messagetemplate;

import com.xie.codegen.processor.api.GenCreateRequest;
import com.xie.codegen.processor.api.GenQueryRequest;
import com.xie.codegen.processor.api.GenResponse;
import com.xie.codegen.processor.api.GenUpdateRequest;
import com.xie.codegen.processor.controller.GenController;
import com.xie.codegen.processor.creator.GenCreator;
import com.xie.codegen.processor.creator.IgnoreCreator;
import com.xie.codegen.processor.mapper.GenMapper;
import com.xie.codegen.processor.query.GenQuery;
import com.xie.codegen.processor.repository.GenRepository;
import com.xie.codegen.processor.service.GenService;
import com.xie.codegen.processor.service.GenServiceImpl;
import com.xie.codegen.processor.updater.GenUpdater;
import com.xie.codegen.processor.updater.IgnoreUpdater;
import com.xie.codegen.processor.vo.GenVo;
import com.xie.common.annotation.FieldDesc;
import com.xie.common.constants.ValidStatus;
import com.xie.jpa.converter.ValidStatusConverter;
import com.xie.jpa.support.BaseJpaAggregate;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;

@GenVo(pkgName = "com.xie.system.domain.message.messagetemplate.vo")
@GenCreator(pkgName = "com.xie.system.domain.message.messagetemplate.creator")
@GenUpdater(pkgName = "com.xie.system.domain.message.messagetemplate.updater")
@GenQuery(pkgName = "com.xie.system.domain.message.messagetemplate.query")

@Table(name = "message_template")
@Data
@Entity
//模板
public class MessageTemplate extends BaseJpaAggregate {


  @FieldDesc(name = "模板编码")
  private String templateCode;

  @FieldDesc(name = "名称")
  private String name;

  @FieldDesc(name = "模板")
  @Column(columnDefinition = "text")
  private String template;

  @FieldDesc(name = "模板类型")
  @Convert(converter = TemplateTypeConverter.class)
  private TemplateType templateType;

  @FieldDesc(name = "描述信息")
  private String description;

  @Convert(converter = ValidStatusConverter.class)
  @IgnoreUpdater
  @IgnoreCreator
  private ValidStatus validStatus;

  public void init() {
    setValidStatus(ValidStatus.VALID);
  }

  public void valid(){
    setValidStatus(ValidStatus.VALID);
  }

  public void invalid(){
    setValidStatus(ValidStatus.INVALID);
  }
}
